shortcutsgroup: fix leak of title
authorAlan Jenkins <alan.christopher.jenkins@gmail.com>
Wed, 12 Oct 2016 15:16:57 +0000 (16:16 +0100)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 13 Oct 2016 13:39:01 +0000 (09:39 -0400)
like previous commit, albeit simpler this time

https://bugzilla.gnome.org/show_bug.cgi?id=772859

gtk/gtkshortcutsgroup.c

index 9e927158e34eb73c17055713aea825bdc3bb4dac..2ea98e81aed094f500154edd0a2b238186e3cfde 100644 (file)
@@ -265,6 +265,24 @@ gtk_shortcuts_group_finalize (GObject *object)
   G_OBJECT_CLASS (gtk_shortcuts_group_parent_class)->finalize (object);
 }
 
+static void
+gtk_shortcuts_group_dispose (GObject *object)
+{
+  GtkShortcutsGroup *self = GTK_SHORTCUTS_GROUP (object);
+
+  /*
+   * Since we overload forall(), the inherited destroy() won't work as normal.
+   * Remove internal widgets ourself.
+   */
+  if (self->title)
+    {
+      gtk_widget_destroy (GTK_WIDGET (self->title));
+      self->title = NULL;
+    }
+
+  G_OBJECT_CLASS (gtk_shortcuts_group_parent_class)->dispose (object);
+}
+
 static void
 gtk_shortcuts_group_class_init (GtkShortcutsGroupClass *klass)
 {
@@ -275,6 +293,7 @@ gtk_shortcuts_group_class_init (GtkShortcutsGroupClass *klass)
   object_class->finalize = gtk_shortcuts_group_finalize;
   object_class->get_property = gtk_shortcuts_group_get_property;
   object_class->set_property = gtk_shortcuts_group_set_property;
+  object_class->dispose = gtk_shortcuts_group_dispose;
 
   widget_class->direction_changed = gtk_shortcuts_group_direction_changed;
   container_class->add = gtk_shortcuts_group_add;